import request from '@/ya/request';

const DictApi = {
	// 新增字典项
	addDict: (data) => {
		return request({
			url: '/api/dictionary',
			method: 'POST',
			data,
			custom: {
				showLoading: false,
				auth: true,
				showSuccess: true,
				successMsg: '新增成功!',
				showError: false,
			},
		});
	},
	// 删除字典项
	delDict: (bdId) => {
		return request({
			url: `api/dictionary/${bdId}`,
			method: 'DELETE',
			custom: {
				showLoading: false,
				auth: true,
				showSuccess: true,
				successMsg: '删除成功!',
				showError: false,
			},
		});
	},
	// 更新字典项
	updateDict: (data) => {
		return request({
			url: '/api/dictionary',
			method: 'PUT',
			data,
			custom: {
				showLoading: false,
				auth: true,
				showSuccess: true,
				successMsg: '删除成功!',
				showError: false,
			},
		});
	},
	// 根据ID查询字典项
	getDictById: (bdId) => {
		return request({
			url: `api/dictionary/${bdId}`,
			method: 'GET',
			custom: {
				showLoading: false,
				auth: true,
				showSuccess: false,
				showError: false,
			},
		});
	},
	// 根据类型查询字典项
	getDictByType: (bdType) => {
		return request({
			url: `api/dictionary/type/${bdType}`,
			method: 'GET',
			custom: {
				showLoading: false,
				auth: false,
				showSuccess: false,
				showError: false,
			},
		});
	},
	// 分页查询字典项
	getDictPages: (params) => {
		return request({
			url: "api/dictionary/page",
			method: 'GET',
			params: params,
			custom: {
				showLoading: false,
				auth: true,
				showSuccess: false,
				showError: false,
			},
		});
	},
};

export default DictApi;